/****************************************************************************
**
** GLEngine.cpp
**
** Copyright (C) August 2014 Hotride
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
*****************************************************************************
*/
//---------------------------------------------------------------------------
#include "stdafx.h"
//---------------------------------------------------------------------------
bool TGLEngine::GLSetupPixelFormat()
{
	int pixelformat;
	PIXELFORMATDESCRIPTOR pfd =
	{
		sizeof(PIXELFORMATDESCRIPTOR),
		1,
		PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
		PFD_TYPE_RGBA,
		24,
		0,0,0,0,0,0,
		0,0,
		0,0,0,0,0,
		32,
		0,
		0,
		PFD_MAIN_PLANE,
		0,
		0,0,
	};

	if ((pixelformat = ChoosePixelFormat(m_DC, &pfd)) == 0)
	{
		MessageBox(NULL, L"ChoosePixelFormat failed", L"Error", MB_OK);
		return false;
	}
	if (SetPixelFormat(m_DC, pixelformat, &pfd) == FALSE)
	{
		MessageBox(NULL, L"SetPixelFormat failed", L"Error", MB_OK);
		return false;
	}
	return true;
}
//---------------------------------------------------------------------------
bool TGLEngine::Install(HWND hWnd)
{
	m_DC = GetDC(hWnd);
	if (!GLSetupPixelFormat()) return false;

	m_RC = wglCreateContext(m_DC);
	if (!m_RC) return false;

	if (!wglMakeCurrent(m_DC, m_RC)) return false;

	glClearColor(0.0, 0.0, 0.0, 1.0);		// Black Background
	glShadeModel(GL_SMOOTH);				// Enables Smooth Color Shading
	glClearDepth(1.0);						// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);				// Enable Depth Buffer
	glDepthFunc(GL_LESS);					// The Type Of Depth Test To Do

	//glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);   //Realy Nice perspective calculations

	glEnable(GL_TEXTURE_2D);

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

	/*int Level = 15; //31 max
	GLfloat lv = 5.0 - (Level * 0.1f);

	GLfloat LightAmbient[4] = { lv, lv, lv, lv };

	GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f };
	GLfloat LightPosition[]= { 0.0f, 0.0f, 0.1f, 0.1f };
	
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT1);
	
	glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);*/

	//glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);

	//glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
	
	/*int idx = 0;

	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0 + idx);

	//float p[4] = {1, 1, 10000, 1};
	//float d[3] = {0, 10, 0};

	glLightfv(GL_LIGHT0 + idx, GL_POSITION, p);
	//glLightfv(GL_LIGHT0 + idx, GL_SPOT_DIRECTION, d);*/

	glViewport(0, 0, g_ClientWidth, g_ClientHeight);
	glOrtho(0.0, g_ClientWidth, g_ClientHeight, 0.0, -100.0, 100.0);
	
	return true;
}
//---------------------------------------------------------------------------
void TGLEngine::SetLightLevel(GLfloat level)
{
	GLfloat Light[4] = {level, level, level, level};

	glLightfv(GL_LIGHT1, GL_AMBIENT, Light);
	
	/*GLfloat LightPos[4] = {-level, -level, level * 0.5f, 0.0f};

	glLightfv(GL_LIGHT1, GL_POSITION, LightPos);

	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);*/
}
//---------------------------------------------------------------------------
void TGLEngine::UpdateRect()
{
	glViewport(0, 0, g_ClientWidth, g_ClientHeight);

	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();

	glOrtho(0.0, g_ClientWidth, g_ClientHeight, 0.0, -100.0, 100.0);

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
}
//---------------------------------------------------------------------------
void TGLEngine::BindTexture(GLuint &Texture, float Width, float Height, PDWORD pixels)
{
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
	glGenTextures(1, &Texture);
	glBindTexture(GL_TEXTURE_2D, Texture);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5_A1, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
}
//---------------------------------------------------------------------------
void TGLEngine::BeginDraw()
{
	g_DrawMode = true;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();
	glDisable(GL_DEPTH_TEST);

	EnableAlpha();
}
//---------------------------------------------------------------------------
void TGLEngine::EndDraw()
{
	g_DrawMode = false;

	DisableAlpha();

	SwapBuffers(m_DC);
}
//---------------------------------------------------------------------------
void TGLEngine::EnableAlpha()
{
	glEnable(GL_ALPHA_TEST);
	glAlphaFunc(GL_GREATER, 0.0f);
}
//---------------------------------------------------------------------------
void TGLEngine::DisableAlpha()
{
	glDisable(GL_ALPHA_TEST);
}
//---------------------------------------------------------------------------
void TGLEngine::ViewPort(int X, int Y, int SizeX, int SizeY)
{
	glViewport(X, g_ClientHeight - Y - SizeY, SizeX, SizeY);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(X, SizeX + X, SizeY + Y, Y, -100.0, 100.0);
	glMatrixMode(GL_MODELVIEW);
}
//---------------------------------------------------------------------------
void TGLEngine::RestorePort()
{
	glViewport(0, 0, g_ClientWidth, g_ClientHeight);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0.0, g_ClientWidth, g_ClientHeight, 0.0, -100.0, 100.0);
	glMatrixMode(GL_MODELVIEW);
}
//---------------------------------------------------------------------------
void TGLEngine::DrawPixel(DWORD Color, float X, float Y)
{
	glColor3b(GetRValue(Color), GetGValue(Color), GetBValue(Color));
	glVertex2f(X, Y);
}
//---------------------------------------------------------------------------
void TGLEngine::DrawList(GLuint Index, float X, float Y)
{
	//glPushMatrix();
	//glLoadIdentity();
	//glTranslatef(X, Y, 0.0f);

	glCallList(Index);

	//glPopMatrix();
	//glTranslatef(0.0, 0.0, 0.1);
}
//---------------------------------------------------------------------------
void TGLEngine::DrawMapGumpTexture(GLuint &Texture, RECT &rc, POINT &bounds, float X, float Y, float Width, float Height)
{
	glBindTexture(GL_TEXTURE_2D, Texture);

	glPushMatrix();
	glLoadIdentity();
	glTranslatef(X, Y, 0.0f);

	float StartX = ((float)rc.left / (float)bounds.x);
	float EndX = ((float)rc.right / (float)bounds.x);
	
	if (StartX < 0.0f) StartX = 0.0f;
	if (EndX > 1.0f) EndX = 1.0f;

	float StartY = ((float)rc.top / (float)bounds.y);
	float EndY = ((float)rc.bottom / (float)bounds.y);
	
	if (StartY < 0.0f) StartY = 0.0f;
	if (EndY > 1.0f) EndY = 1.0f;

	glBegin(GL_QUADS);
		glTexCoord2f(StartX, EndY); glVertex2f(0.0f, Height);
		glTexCoord2f(EndX, EndY); glVertex2f(Width, Height);
		glTexCoord2f(EndX, StartY); glVertex2f(Width, 0.0f);
		glTexCoord2f(StartX, StartY); glVertex2f(0.0f, 0.0f);
	glEnd();

	glPopMatrix();
	glTranslatef(0.0, 0.0, 0.1);
}
//---------------------------------------------------------------------------
void TGLEngine::DrawPolygoneSafe(DWORD Color, float X, float Y, float Width, float Height)
{
	glDisable(GL_TEXTURE_2D);

	glPushMatrix();
	glLoadIdentity();
	glTranslatef(X, Y, 0.0f);
	
	glColor3b(GetRValue(Color), GetGValue(Color), GetBValue(Color));

	glBegin(GL_QUADS);
		glVertex2f(0.0f, Height);
		glVertex2f(Width, Height);
		glVertex2f(Width, 0.0f);
		glVertex2f(0.0f, 0.0f);
	glEnd();
	
	glPopMatrix();
	glTranslatef(0.0, 0.0, 0.1);
	
	glColor3f(1.0f, 1.0f, 1.0f);
	glEnable(GL_TEXTURE_2D);
}
//---------------------------------------------------------------------------
void TGLEngine::DrawPolygone(DWORD Color, float X, float Y, float Width, float Height)
{
	glPushMatrix();
	glLoadIdentity();
	glTranslatef(X, Y, 0.0f);
	
	glColor3b(GetRValue(Color), GetGValue(Color), GetBValue(Color));

	glBegin(GL_QUADS);
		glVertex2f(0.0f, Height);
		glVertex2f(Width, Height);
		glVertex2f(Width, 0.0f);
		glVertex2f(0.0f, 0.0f);
	glEnd();
	
	glPopMatrix();
	glTranslatef(0.0, 0.0, 0.1);
}
//---------------------------------------------------------------------------
void TGLEngine::DrawLine(DWORD Color, float X, float Y, float TargetX, float TargetY)
{
	glDisable(GL_TEXTURE_2D);

	glPushMatrix();
	glLoadIdentity();
	
	glColor3b(GetRValue(Color), GetGValue(Color), GetBValue(Color));

	glBegin(GL_LINES);
		glVertex2f(X, Y);
		glVertex2f(TargetX, TargetY);
	glEnd();
	
	glPopMatrix();
	//glTranslatef(0.0, 0.0, 0.1);

	glColor3f(1.0f, 1.0f, 1.0f);
	glEnable(GL_TEXTURE_2D);
}
//---------------------------------------------------------------------------
void TGLEngine::DrawTransparencyPolygone(float X, float Y, float Width, float Height)
{
	return;
	//glDisable(GL_TEXTURE_2D);
	glPushMatrix();
	glLoadIdentity();
	glTranslatef(X, Y, 0.0f);
	
	PDWORD pixels = (PDWORD)malloc(Width * Height * 4);
	memset(pixels, 0, Width * Height * 4);
	GLuint Texture;

	BindTexture(Texture, Width, Height, pixels);
	
	glBindTexture(GL_TEXTURE_2D, Texture);
	free(pixels);

	glEnable(GL_BLEND);
	//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	//glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
	glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA);
	//glDisable( GL_DEPTH_TEST );

	glBegin(GL_QUADS);
		glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, Height);
		glTexCoord2f(1.0f, 1.0f); glVertex2f(Width, Height);
		glTexCoord2f(1.0f, 0.0f); glVertex2f(Width, 0.0f);
		glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
	glEnd();
	
	glDisable(GL_BLEND);

	glDeleteTextures(1, &Texture);
	
	glPopMatrix();
	glTranslatef(0.0, 0.0, 0.1);
	//glEnable(GL_TEXTURE_2D);
}
//---------------------------------------------------------------------------
void TGLEngine::DrawMapTexture(GLuint &Texture, float X, float Y, float Width, float Height, RECT &rc)
{
	glBindTexture(GL_TEXTURE_2D, Texture);

	glPushMatrix();
	glLoadIdentity();

	glTranslatef(X + 22, Y + 22 - rc.left, 0.0f);
	
	glBegin(GL_QUADS);
		glTexCoord2f(0.0f, 1.0f); glVertex2f(-22.0f, 0.0f + rc.top); //<
		glTexCoord2f(1.0f, 1.0f); glVertex2f(0.0f, 22.0f + rc.right); //v
		glTexCoord2f(1.0f, 0.0f); glVertex2f(22.0f, 0.0f + rc.bottom); //>
		glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, -22.0f); //^
	glEnd();

	glPopMatrix();
	glTranslatef(0.0, 0.0, 0.1);
	glRotatef(0.0f, 0.0f, 0.0f, 0.0f);
}
//---------------------------------------------------------------------------
void TGLEngine::DrawBlend(GLuint &Texture, float X, float Y, float Width, float Height)
{
	glBindTexture(GL_TEXTURE_2D, Texture);

	glPushMatrix();
	glLoadIdentity();
	glTranslatef(X, Y, 0.0f);

	glEnable(GL_BLEND);
	
	glBlendFunc(GL_SRC_COLOR, GL_SRC_ALPHA_SATURATE);
	
	//glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_DST_COLOR);



	//glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
	//glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA);
	
	//glBlendFunc(GL_ONE, GL_SRC_COLOR);
	
	//glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA);
	//glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
	//glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA);
	//glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_COLOR);

	glBegin(GL_QUADS);
		glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, Height);
		glTexCoord2f(1.0f, 1.0f); glVertex2f(Width, Height);
		glTexCoord2f(1.0f, 0.0f); glVertex2f(Width, 0.0f);
		glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
	glEnd();
	
	glDisable(GL_BLEND);

	glPopMatrix();
	glTranslatef(0.0, 0.0, 0.1);
}
//---------------------------------------------------------------------------
void TGLEngine::Draw(GLuint &Texture, float X, float Y, float Width, float Height)
{
	glBindTexture(GL_TEXTURE_2D, Texture);

	glPushMatrix();
	glLoadIdentity();
	glTranslatef(X, Y, 0.0f);

	glBegin(GL_QUADS);
		glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, Height);
		glTexCoord2f(1.0f, 1.0f); glVertex2f(Width, Height);
		glTexCoord2f(1.0f, 0.0f); glVertex2f(Width, 0.0f);
		glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
	glEnd();

	glPopMatrix();
	glTranslatef(0.0, 0.0, 0.1);
}
//---------------------------------------------------------------------------
void TGLEngine::Draw(GLuint &Texture, float X, float Y, float Width, float Height, bool Mirror)
{
	glBindTexture(GL_TEXTURE_2D, Texture);

	glPushMatrix();
	glLoadIdentity();
	glTranslatef(X, Y, 0.0f);

	if (Mirror)
	{
		glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 1.0f); glVertex2f(Width, Height);
			glTexCoord2f(1.0f, 1.0f); glVertex2f(0.0f, Height);
			glTexCoord2f(1.0f, 0.0f); glVertex2f(0.0f, 0.0f);
			glTexCoord2f(0.0f, 0.0f); glVertex2f(Width, 0.0f);
		glEnd();
	}
	else
	{
		glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, Height);
			glTexCoord2f(1.0f, 1.0f); glVertex2f(Width, Height);
			glTexCoord2f(1.0f, 0.0f); glVertex2f(Width, 0.0f);
			glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
		glEnd();
	}

	glPopMatrix();
	glTranslatef(0.0, 0.0, 0.1);
}
//---------------------------------------------------------------------------
void TGLEngine::Draw(GLuint &Texture, float X, float Y, float Width, float Height, float DrawWidth, float DrawHeight)
{
	glBindTexture(GL_TEXTURE_2D, Texture);

	glPushMatrix();
	glLoadIdentity();
	glTranslatef(X, Y, 0.0f);

	float draw_countX = DrawWidth / Width;
	float draw_countY = DrawHeight / Height;

	glBegin(GL_QUADS);
		glTexCoord2f(0.0f, draw_countY); glVertex2f(0.0f, DrawHeight);
		glTexCoord2f(draw_countX, draw_countY); glVertex2f(DrawWidth, DrawHeight);
		glTexCoord2f(draw_countX, 0.0f); glVertex2f(DrawWidth, 0.0f);
		glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
	glEnd();

	glPopMatrix();
	glTranslatef(0.0, 0.0, 0.1);
}
//---------------------------------------------------------------------------
void TGLEngine::DrawResizepic(PTEXTURE_HEADER *th, float X, float Y, float W, float H)
{
	IFOR(i, 0, 9)
	{
		glPushMatrix();
		glLoadIdentity();

		glBindTexture(GL_TEXTURE_2D, th[i]->Texture);

		float DW = (float)th[i]->Width;
		float DH = (float)th[i]->Height;

		switch (i)
		{
			case 0:
			{
				glTranslatef(X, Y, 0.0f);

				glBegin(GL_QUADS);
					glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, DH);
					glTexCoord2f(1.0f, 1.0f); glVertex2f(DW, DH);
					glTexCoord2f(1.0f, 0.0f); glVertex2f(DW, 0.0f);
					glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
				glEnd();
				break;
			}
			case 1:
			{
				glTranslatef(X + th[0]->Width, Y, 0.0f);

				DW = W - th[0]->Width - th[2]->Width;
				if (DW < 1) break;
				float draw_count = DW / th[i]->Width;

				glBegin(GL_QUADS);
					glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, DH);
					glTexCoord2f(draw_count, 1.0f); glVertex2f(DW, DH);
					glTexCoord2f(draw_count, 0.0f); glVertex2f(DW, 0.0f);
					glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
				glEnd();
				break;
			}
			case 2:
			{
				glTranslatef(X + W - DW, Y, 0.0f);

				glBegin(GL_QUADS);
					glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, DH);
					glTexCoord2f(1.0f, 1.0f); glVertex2f(DW, DH);
					glTexCoord2f(1.0f, 0.0f); glVertex2f(DW, 0.0f);
					glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
				glEnd();
				break;
			}
			case 3:
			{
				glTranslatef(X, Y + th[0]->Height, 0.0f);

				DH = H - th[0]->Height - th[5]->Height;
				if (DH < 1) break;
				float draw_count = DH / th[i]->Height;

				glBegin(GL_QUADS);
					glTexCoord2f(0.0f, draw_count); glVertex2f(0.0f, DH);
					glTexCoord2f(1.0f, draw_count); glVertex2f(DW, DH);
					glTexCoord2f(1.0f, 0.0f); glVertex2f(DW, 0.0f);
					glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
				glEnd();
				break;
			}
			case 4:
			{
				glTranslatef(X + W - DW, Y + th[2]->Height, 0.0f);

				DH = H - th[2]->Height - th[7]->Height;
				if (DH < 1) break;
				float draw_count = DH / th[i]->Height;

				glBegin(GL_QUADS);
					glTexCoord2f(0.0f, draw_count); glVertex2f(0.0f, DH);
					glTexCoord2f(1.0f, draw_count); glVertex2f(DW, DH);
					glTexCoord2f(1.0f, 0.0f); glVertex2f(DW, 0.0f);
					glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
				glEnd();
				break;
			}
			case 5:
			{
				glTranslatef(X, Y + H - DH, 0.0f);

				glBegin(GL_QUADS);
					glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, DH);
					glTexCoord2f(1.0f, 1.0f); glVertex2f(DW, DH);
					glTexCoord2f(1.0f, 0.0f); glVertex2f(DW, 0.0f);
					glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
				glEnd();
				break;
			}
			case 6:
			{
				glTranslatef(X + th[5]->Width, Y + H - DH, 0.0f);

				DW = W - th[5]->Width - th[7]->Width;
				if (DW < 1) break;
				float draw_count = DW / th[i]->Width;

				glBegin(GL_QUADS);
					glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, DH);
					glTexCoord2f(draw_count, 1.0f); glVertex2f(DW, DH);
					glTexCoord2f(draw_count, 0.0f); glVertex2f(DW, 0.0f);
					glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
				glEnd();
				break;
			}
			case 7:
			{
				glTranslatef(X + W - DW, Y + H - DH, 0.0f);

				glBegin(GL_QUADS);
					glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, DH);
					glTexCoord2f(1.0f, 1.0f); glVertex2f(DW, DH);
					glTexCoord2f(1.0f, 0.0f); glVertex2f(DW, 0.0f);
					glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
				glEnd();
				break;
			}
			case 8:
			{
				glTranslatef(X + th[0]->Width, Y + th[0]->Height, 0.0f);

				DW = W - th[0]->Width - th[2]->Width;
				if (DW < 1) break;

				DH = H - th[2]->Height - th[7]->Height;
				if (DH < 1) break;

				float draw_countX = DW / th[i]->Width;
				float draw_countY = DH / th[i]->Height;

				glBegin(GL_QUADS);
					glTexCoord2f(0.0f, draw_countY); glVertex2f(0.0f, DH);
					glTexCoord2f(draw_countX, draw_countY); glVertex2f(DW, DH);
					glTexCoord2f(draw_countX, 0.0f); glVertex2f(DW, 0.0f);
					glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
				glEnd();
				break;
			}
			default: break;
		}

		glPopMatrix();
		glTranslatef(0.0, 0.0, 0.1);
	}
}
//---------------------------------------------------------------------------